/*************************************************
 * 
 * Copyright by Bruno Eberhard
 * 
 * Created on 31.07.2005
 *
 *************************************************/
package fightplan.business;

import java.io.Serializable;

public enum AgeType implements Serializable, Comparable<AgeType> {
	CHILDREN("Kinder"), J1("Jugend"), J2("Junioren"), ELITE("Elite"), UNSET("Alle Stufen"), ALL("Alle Stufen");

	private static final long serialVersionUID = 1;

	public static final AgeType[] ALL_VALUES = new AgeType[] { CHILDREN, J1, J2, ELITE, UNSET, ALL };
	public static final AgeType[] VALUES = new AgeType[] { CHILDREN, J1, J2, ELITE };
	public static final AgeType[] VALUES_AND_UNSET = new AgeType[] { UNSET, CHILDREN, J1, J2, ELITE };
	public static final AgeType[] VALUES_AND_ALL = new AgeType[] { ALL, CHILDREN, J1, J2, ELITE };

	private String name;

	AgeType(String name) {
		this.name = name;
	}

	public static AgeType parse(String s) {
		if (s == null || s.length() == 0)
			return UNSET;

		if (s.toUpperCase().contains(CHILDREN.getName().toUpperCase()))
			return CHILDREN;
		if (s.toUpperCase().contains(J1.getName().toUpperCase()))
			return J1;
		if (s.toUpperCase().contains(J2.getName().toUpperCase()))
			return J2;
		if (s.toUpperCase().contains(ELITE.getName().toUpperCase()))
			return ELITE;

		return UNSET;
	}

	// get / set

	public String getName() {
		return name;
	}

	//

	public boolean comaptible(AgeType g) {
		return ALL.equals(this) || equals(g);
	}

}
